<?php 
set_time_limit(0);
ini_set("memory_limit", "12M");
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
unset($_SESSION['s_searchs']);

include '../connection/connection.php';
$searchmonth = $_REQUEST['s_month'];
$searchyear = $_REQUEST['s_year'];
$winH = 520;
	if(isset($_REQUEST['winH'])) $winH = $_REQUEST['winH'];
	
$query = "select logsearch.logDatetime,caruser.iUser as UserID,logsearch.dtStart,logsearch.dtEnd,logsearch.carType,logsearch.carnum,logsearch.isReg from logsearch,caruser
				where caruser.iUser=logsearch.iUser and YEAR(logDatetime)='%s' and MONTH(logDatetime)='%s'";
$query = vsprintf($query,array($searchyear,$searchmonth));
$listSearch = mysql_query($query,$connection);
$index = 0;
$mylist = array();
?>
	<div  id="divscroll" style="overflow:scroll;overflow-x: hidden; width:100%; height:<?=$winH?>px; background-color: #ffffff">
	               <table cellpadding="0" cellspacing="0" border="0" width="100%" class="tbchung" style="margin-top:0" id="tablebody">
						 <tbody>
						 
<?php 

					
 while ($row = mysql_fetch_array($listSearch)){
 		$index+=1;
 		$cartype_ = rtrim($row[cartype]);
		$mylist[$index] = array($row[logDatetime],$row[UserID],$row[dtStart],$row[dtEnd],$cartype_,$row[carnum],$row[isReg]); 
			 
?>
		 <tr>
		 	<td width="14%"><?=$row[logDatetime]?></td>
		 	<td width="14%"><?=$row[UserID]?></td>
		 	<td width="14%"><?=$row[dtStart]?></td>
		 	<td width="14%"><?=$row[dtEnd]?></td>
		 	<td width="14%"><?=$cartype_?>&nbsp;</td>
		 	<td width="14%"><?=$row[carnum]?>&nbsp;</td>
		 	<td  class="last"><?=$row[isReg]?></td>
		 </tr> 
						 
<?php  
	}
	if ($index>0 and $index<$winH/28) {
	 	foreach(range(0,$winH/28-$index) as $i){
	 		?>
	 		<tr>
		 	<td width="14%">&nbsp;</td>
		 	<td width="14%">&nbsp;</td>
		 	<td width="14%">&nbsp;</td>
		 	<td width="14%">&nbsp;</td>
		 	<td width="14%">&nbsp;</td>
		 	<td width="14%">&nbsp;</td>
		 	<td  class="last">&nbsp;</td>
		 	</tr>
	 	<?php }
	}
	?>
</tbody>       
	               </table>
</div>
<?php 
       		
$_SESSION['s_searchs'] = $mylist;
mysql_close($connection);
?>  